home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / shareware / AutoHotkey104407_Install.exe / Extras / Run this to install syntax and clip files for PSPad.ahk < prev    next >
Encoding:
Text File  |  2005-02-11  |  8.9 KB  |  277 lines

  1. ;;; ============================================================================
  2. ;;;   FILENAME: Run this to install syntax and clip files for PSPad.ahk
  3. ;;; ============================================================================
  4. ;;;   Install AutoHotkey syntax highlighting and clip files in PSPad
  5. ;;; ============================================================================
  6.  
  7. ;;;   AUTHOR:  Scott Greenberg  
  8. ;;;   COMPANY: SG Technology
  9. ;;;   VERSION: 1.0.1, 02/05/2005 - 02/08/2005
  10. ;;;   WEBSITE: http://gogogadgetscott.info/
  11. ;;;   Copyright 2005. SG Technology. All rights reserved.
  12. ;;;
  13. ;;; ============================================================================
  14. ;;;   HISTORY:
  15. ;;;    1.0.3
  16. ;;;     - The "remove the [ ] brackets" mode overwrites the DEF file (not append).
  17. ;;;    1.0.2
  18. ;;;     - The INI file is copied to PSPad's Syntax folder, not its Context folder.
  19. ;;;     - Fixed the "remove the [ ] brackets" mode to use backslash as escape char.
  20. ;;;     - Original ini file is backed up prior to being overwritten.
  21. ;;;    1.0.1
  22. ;;;     - Fixed some spelling errors.
  23. ;;;     - Removed ] (typo) from line No 42.
  24. ;;;     - Changed "clip library files" to "clip files".
  25. ;;; ============================================================================
  26. ;;;   DISCLAIMER:
  27. ;;;   Permission to use, copy, modify, and distribute this software 
  28. ;;;   for any purpose and without fee is hereby granted, provided 
  29. ;;;   that the above copyright notice appears in all copies and that 
  30. ;;;   both that copyright notice and this permission notice appear in 
  31. ;;;   all supporting documentation.
  32. ;;;
  33. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
  34. ;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
  35. ;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
  36. ;;; ============================================================================
  37.  
  38. ;;; Directives, required by this script (do not change)
  39. #SingleInstance force
  40. #EscapeChar \
  41. SetBatchLines,-1
  42. ScriptTitle = AutoHotkey PSPpad Setup
  43. ;;;  Used to aid in bugging script
  44. ;; debugging on  = 1
  45. ;; debugging off = 0
  46. bDebug = 0
  47. IfNotEqual, bDebug, 1
  48. {
  49.     MsgBox, 4, %ScriptTitle%, This will install file for PSPad to handle AutoHotkey scripts.\nWould you like to continue with the install?
  50.     IfMsgBox, No
  51.         ExitApp
  52. }
  53. ;;; Get PSPad exe path from registry.
  54. RegRead, PSPadExe, HKCU, Software\\PSPad, PSPadExe
  55. ;;; Remove quotes from path
  56. StringReplace, PSPadExe, PSPadExe, ",, A
  57. IfNotEqual, bDebug, 0
  58.     PSPadExe = C:\\Program Files\\PSPad\\PSPad.exe
  59. ;;; Allow user to select from dialog, when unable to locate PSPad
  60. IfNotExist, %PSPadExe%
  61.     FileSelectFile, PSPadExe, 1, %A_ProgramFiles%\\PSPad\\PSPad.exe, Select the PSPad executable., Executable (*.exe)
  62. IfNotExist, %PSPadExe%
  63.     Goto, DownloadPSPad
  64. SplitPath, PSPadExe, PSPadName, PSPadDir
  65. ;;; Get AutoHotkey exe path from registry.
  66. RegRead, AHKExe, HKLM, SOFTWARE\\AutoHotkey, InstallDir
  67. AHKExe = %AHKExe%\\AutoHotkey.exe
  68. ;;; Allow user to select from dialog, when unable to locate AutoHotkey
  69. IfNotExist, %AHKExe%
  70.     FileSelectFile, AHKExe, 1, %A_ProgramFiles%\\AutoHotkey\\AutoHotkey.exe, Select the AutoHotkey executable., Executable (*.exe)
  71. IfNotExist, %AHKExe%
  72.     Goto, DownloadAHK
  73. SplitPath, AHKExe, AHKName, AHKDir
  74. ;;; Close PSPad
  75. Process, Exist, %PSPadName%
  76. if ErrorLevel <> 0
  77. {
  78.     If bDebug <> 1
  79.         Process, Close, %PSPadName%
  80. }
  81. ;;; Copy files to PSPad dir
  82. file = %A_WORKINGDIR%\\AutoHotkey.def
  83. IfExist, %file%
  84. {
  85.     ;;; Added by beardboy:
  86.     MsgBox, 4, Customize the clip file (.DEF), Would you like to remove the [ ] brackets from optional parameters of commands in the clip file?, 30
  87.     IfMsgBox, Yes
  88.     {
  89.         FileDelete, %PSPadDir%\\Context\\AutoHotkey.def  ; If it exists, overwrite.
  90.         Loop, read, %file%, %PSPadDir%\\Context\\AutoHotkey.def
  91.         {
  92.             IfInString, A_LoopReadLine, [,
  93.             {
  94.                 StringReplace, temp, a_loopreadline, %a_space%[,, All
  95.                 StringReplace, temp, temp, ],, All
  96.                 StringReplace, temp, temp, %a_space%\,, \,, All
  97.                 FileAppend, %temp%\n
  98.             }
  99.             else
  100.                 FileAppend, %A_LoopReadLine%\n
  101.         }
  102.     }
  103.     else
  104.         FileCopy, %file%, %PSPadDir%\\Context\\, 1
  105. }
  106.  
  107. ;;; End
  108.  
  109. file = %A_WORKINGDIR%\\AutoHotkey.ini
  110. IfExist, %file%
  111. {
  112.     ; Make backup of old file if it exists and if there isn't already a backup file (this relies
  113.     ; on it failing to do anything otherwise):
  114.     FileMove, %PSPadDir%\\Syntax\\AutoHotkey.ini, %PSPadDir%\\Syntax\\AutoHotkey (previous).ini
  115.     FileCopy, %file%, %PSPadDir%\\Syntax\\, 1
  116. }
  117. ;;; Get current user highlighter settings from ini
  118. PSPadINI = %PSPadDir%\\PSPad.INI
  119. IniRead, UserHighLighterName1, %PSPadINI%, Config, UserHighLighterName, General
  120. IniRead, UserHighLighterName2, %PSPadINI%, Config, UserHighLighterName1, General
  121. IniRead, UserHighLighterName3, %PSPadINI%, Config, UserHighLighterName2, General
  122. IniRead, UserHighLighterName4, %PSPadINI%, Config, UserHighLighterName3, General
  123. IniRead, UserHighLighterName5, %PSPadINI%, Config, UserHighLighterName4, General
  124. FoundE = 0
  125. FoundP = 0
  126. Loop, 5
  127. {
  128.     value := UserHighLighterName%a_index%
  129.     If value =
  130.     {
  131.         FoundE = %a_index%
  132.         break
  133.     }
  134.     StringGetPos, iPos, value, General
  135.     IfGreaterOrEqual, iPos, 0
  136.     {
  137.         FoundE = %a_index%
  138.         break
  139.     }
  140.     StringGetPos, iPos, value, AutoHotkey
  141.     IfGreaterOrEqual, iPos, 0
  142.     {
  143.         FoundP = %a_index%
  144.         break
  145.     }
  146. }
  147. If FoundP
  148. {
  149.     MsgBox, 4, %ScripT%, PSPad is already setup to handle AutoHotkey scripts.\nWould you like to continue anyways?,
  150.     IfMsgBox, No
  151.         ExitApp, -1  
  152.     FoundE = %FoundP%
  153. }
  154. ;;; Setup AutoHotkey as an user highlighter in ini
  155. If FoundE <> 0
  156. {
  157.     EnvSub, FoundE, 1
  158.     IfLessOrEqual, FoundE, 0
  159.         FoundE = 
  160.     Key = UserHighLighterName%FoundE%
  161.     IniWrite, AutoHotkey, %PSPadINI%, Config, %Key%
  162. }
  163. else
  164. {
  165.     Gosub, SelectUserHighLighter
  166.     EnvSub, FoundE, 1
  167.     IfLessOrEqual, FoundE, 0
  168.         FoundE = 
  169.     Key = UserHighLighterName%FoundE%
  170.     IniWrite, AutoHotkey, %PSPadINI%, Config, %Key%
  171. }
  172. ;;; Added configuration for highlighter to ini
  173. IniWrite, AutoHotkey (*.ahk)|*.ahk, %PSPadINI%, AutoHotkey, Filter
  174. value = %AHKDir%\\AutoHotkey.chm
  175. IniWrite, %value%, %PSPadINI%, AutoHotkey, Compilator Help
  176. value = %AHKDir%\\Compiler\\Ahk2Exe.exe
  177. IniWrite, %value%, %PSPadINI%, AutoHotkey, Compilator File
  178. IniWrite, /in "\%File\%", %PSPadINI%, AutoHotkey, Compilator Param
  179. value = Run,|%AHKDir%\\AutoHotkey.exe| |\%File\%|ยบ
  180. IniWrite, %value%, %PSPadINI%, AutoHotkey, Prog0
  181. value = AU3_Spy,|%AHKDir%\\AU3_Spy.exe|
  182. IniWrite, %value%, %PSPadINI%, AutoHotkey, Prog1
  183. MsgBox, 4, ScriptTitle, Whould you like to setup custom colors w/ light blue background?, 30
  184. IfMsgBox, Yes
  185. {
  186.     IniWrite, 0000800000FFF0DC010, %PSPadINI%, AutoHotkey, Comment
  187.     IniWrite, 1FFFFFFF00FFF0DC000, %PSPadINI%, AutoHotkey, Identifier
  188.     IniWrite, 0080400000FFF0DC100, %PSPadINI%, AutoHotkey, Key
  189.     IniWrite, 000080FF00FFF0DC100, %PSPadINI%, AutoHotkey, Key words 2
  190.     IniWrite, 0000800000FFF0DC100, %PSPadINI%, AutoHotkey, Key words 3
  191.     IniWrite, 000000FF00FFF0DC000, %PSPadINI%, AutoHotkey, Label
  192.     IniWrite, 1FFFFFFF00FFF0DC000, %PSPadINI%, AutoHotkey, Number
  193.     IniWrite, 000000FF00FFF0DC010, %PSPadINI%, AutoHotkey, Preprocessor
  194.     IniWrite, 0000008000FFF0DC100, %PSPadINI%, AutoHotkey, Reserved word
  195.     IniWrite, 0080800000FFF0DC000, %PSPadINI%, AutoHotkey, Space
  196.     IniWrite, 000000FF00FFF0DC000, %PSPadINI%, AutoHotkey, String
  197.     IniWrite, 0000000000FFF0DC000, %PSPadINI%, AutoHotkey, Symbol
  198. }
  199.  
  200. ;;; Open PSPad
  201. If bDebug <> 1
  202.     Run, %PSPadExe%
  203.  
  204. ExitApp
  205.  
  206.  
  207. SelectUserHighLighter:
  208. valSet := 0
  209. Gui, Font, s10 cBlue, Lucida Console
  210. Gui, Add, Text,, Select a User HighLighter to replace:
  211. Gui, Add, Radio, checked vFoundE, &1 %UserHighLighterName1%
  212. Loop, 4
  213. {
  214.     index := a_index + 1
  215.     value := UserHighLighterName%index%
  216.     Gui, Add, Radio,, &%index% %value%
  217. }
  218. Gui, Add, Button, Default, &OK
  219. Gui, Show, AutoSize, ScriptTitle
  220. Loop
  221. {
  222.     if valSet
  223.         break
  224. }
  225. Gui, Submit
  226. Gui, Destroy
  227. Return
  228.  
  229. ButtonOK:
  230. valSet = 1
  231. Return
  232.  
  233. GuiClose:
  234. Gui, Submit
  235. Gui, Destroy
  236. valSet = 1
  237. Return
  238.  
  239. DownloadPSPad:
  240. url = http://www.pspad.com/
  241. valSet := 0
  242. Gui, Font, norm
  243. Gui, Add, Text,, It appears PSPad is not installed. Unable to continue.
  244. Gui, Font, underline 
  245. Gui, Add, Text, cBlue gOpenLink, Click here to Download PSPad.
  246. Gui, Font, norm
  247. Gui, Add, Button, Default, &OK
  248. Gui, Show, AutoSize, ScriptTitle
  249. Loop
  250. {
  251.     if valSet
  252.         break
  253. }
  254. ExitApp -1
  255.  
  256. DownloadAHK:
  257. url = http://www.autohotkey.com/
  258. valSet := 0
  259. Gui, Font, norm
  260. Gui, Add, Text,, We sure AutoHotkey is installed but we are unable to find it. Unable to continue.
  261. Gui, Font, underline
  262. Gui, Add, Text, cBlue gOpenLink, Click here to Download AutoHotkey.
  263. Gui, Font, norm
  264. Gui, Add, Button, Default, &OK
  265. Gui, Show, AutoSize, ScriptTitle
  266. Loop
  267. {
  268.     if valSet
  269.         break
  270. }
  271. ExitApp -1
  272.  
  273. OpenLink: 
  274. Run, %url%
  275. ExitApp -1
  276. return
  277.